package com.ctrip.study.dp.proxy;

import java.io.File;
import java.io.FileInputStream;

import org.apache.commons.io.IOUtils;

public class FileClassLoader extends ClassLoader{
	
	@Override
	protected Class<?> findClass(String name) throws ClassNotFoundException {
		try {
			FileInputStream fis = new FileInputStream(new File(name));
			byte[] classByte = IOUtils.toByteArray(fis);
			return defineClass(null, classByte, 0, classByte.length);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return super.findClass(name);
	}

}
